<?php
/**
 * @link https://www.kancloud.cn/cleverstone/ymb2
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */

namespace builder\tree_table\util;

/**
 * 工具栏选项卡 - 选项
 * @author cleverstone
 * @since ym2.0
 */
class TTToolbarTab
{
    private $_options = [
        'title' => '',
        'icon' => '',
        'params' => [],
        'defaultChecked' => false,
    ];

    /**
     * 标题
     * @param string $title
     * @return $this
     */
    public function title($title)
    {
        $this->_options['title'] = (string)$title;
        return $this;
    }

    /**
     * 图标
     * @param string $icon
     * @return $this
     */
    public function icon($icon)
    {
        $this->_options['icon'] = (string)$icon;
        return $this;
    }

    /**
     * 设置用于切换请求的参数
     * @param array $params
     * @return $this
     */
    public function params(array $params)
    {
        $this->_options['params'] = $params;
        return $this;
    }

    /**
     * 设置选中
     * @return $this
     */
    public function checked()
    {
        $this->_options['defaultChecked'] = true;
        return $this;
    }

    /**
     * 输出
     * @return array
     */
    public function _toArray()
    {
        return $this->_options;
    }
}